<?php

/**
 * @Author: Wang Chunsheng 2192138785@qq.com
 * @Date:   2020-03-13 04:06:57
 * @Last Modified by:   Wang Chunsheng 2192138785@qq.com
 * @Last Modified time: 2020-03-24 20:54:49
 */


namespace api\controllers;

use Yii;
use api\controllers\AController;
use common\helpers\MapHelper;
use common\helpers\ResultHelper;

class MapController extends AController
{
    public $modelClass = '';
    protected $authOptional = ['distance'];

    /**
     * @SWG\Get(path="/map/distance",
     *     tags={"地图"},
     *     summary="根据经纬度获取省市区",
     *     @SWG\Response(
     *         response = 200,
     *         description = "根据经纬度获取省市区",
     *         @SWG\Schema(ref = "#/definitions/User")
     *     ),
     *     @SWG\Parameter(
     *      in="query",
     *      name="lat",
     *      type="string",
     *      description="纬度",
     *      required=true,
     *    ),
     *     @SWG\Parameter(
     *      in="query",
     *      name="lng",
     *      type="string",
     *      description="经度",
     *      required=true,
     *    ),
     *
     * )
     */
    public function actionDistance()
    {
        $lng = Yii::$app->request->get('lng');
        $lat = Yii::$app->request->get('lat');
        $data = MapHelper::distance($lng, $lat);
        return ResultHelper::json(200, '获取成功', $data);
    }
}
